﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:bsl="clr-namespace:Silverlight4Demo.Utility.CustomControl" >
    <!-- add the namespace of control into resource dictionary -->
    <Style TargetType="bsl:CoolDownButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="bsl:CoolDownButton">
                    <Grid x:Name="LayoutRoot">
                        <!-- 
                        Define the animation or the transitions of each state of the control.
                        VisualStateManager.GoToState method will be called with the names of these states
                        -->
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="NormalStates">
                                <VisualState Name="Normal"/>
                                <VisualState Name="MouseOver" >
                                    <Storyboard >
                                        <DoubleAnimation 
                                            Storyboard.TargetName="innerButton" 
                                            Storyboard.TargetProperty="(UIElement.StrokeThickness)" 
                                            Duration="0" To="6"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimation 
                                            Storyboard.TargetName="innerButton" 
                                            Storyboard.TargetProperty="(UIElement.StrokeThickness)" 
                                            Duration="0" To="2"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup Name="CoolDownStates">
                                <VisualState Name="Available"/>
                                <VisualState Name="CoolDown">
                                    <Storyboard>
                                        <DoubleAnimation 
                                            Storyboard.TargetName="corePart" 
                                            Storyboard.TargetProperty="(UIElement.Opacity)" 
                                            Duration="0" To=".75"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <!-- define the basic appearance of the control with the basic system control (rectangle , textblock and so on )-->
                        <Rectangle 
                            StrokeThickness="4" 
                            Stroke="Navy" 
                            Fill="AliceBlue" 
                            RadiusX="4" 
                            RadiusY="4" 
                            x:Name="innerButton" />
                        <TextBlock 
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Center" 
                            Text="Test2" 
                            TextWrapping="Wrap"/>
                        <Rectangle 
                            Opacity="0" 
                            Fill="#FF000000" 
                            Stroke="#FF000000" 
                            RenderTransformOrigin="0.5,0.5" 
                            RadiusY="4" RadiusX="4" 
                            x:Name="corePart">
                            <Rectangle.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform 
                                    ScaleX="1" 
                                    ScaleY="1"/>
                                </TransformGroup>
                            </Rectangle.RenderTransform>
                        </Rectangle>
                    </Grid>
                </ControlTemplate>

            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
